//package com.quartet.modules.equipment.controller;
//
//
//import cn.hutool.core.bean.BeanUtil;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.extension.api.ApiController;
//import com.quartet.api.ApiResult;
//import com.quartet.modules.equipment.dto.TRiskInfoRequestDto;
//import com.quartet.modules.equipment.dto.TRiskInfoResponseDto;
//import com.quartet.modules.equipment.entity.TRiskInfo;
//import com.quartet.modules.equipment.service.TRiskInfoService;
//import com.quartet.modules.service.aspect.AuthKeyValidated;
//import com.quartet.modules.vehicle.entity.TVehicleInfo;
//import com.quartet.modules.vehicle.service.TVehicleInfoService;
//import com.quartet.utils.enums.RiskInfoTypeEnum;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.util.CollectionUtils;
//import org.springframework.util.ObjectUtils;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * 风险信息表(TRiskInfo)表控制层
// *
// * @author makejava
// * @since 2021-05-04 16:46:16
// */
//@RestController
//@RequestMapping("tRiskInfo")
//@Api(tags = "业务：风险信息")
//@Slf4j
//public class TRiskInfoController  {
//    /**
//     * 服务对象
//     */
//    @Resource
//    private TRiskInfoService tRiskInfoService;
//
//    /**
//     * 服务对象
//     */
//    @Resource
//    private TVehicleInfoService tVehicleInfoService;
//
//    /**
//     * 分页查询所有数据
//     *
//     * @param riskInfoRequestDto 查询实体
//     * @return 所有数据
//     */
//    @ApiOperation("分页查询所有风险信息")
//    @PostMapping("/selectRiskByCondition")
//    @AuthKeyValidated("alarm")
//    public ApiResult<List<TRiskInfoResponseDto>> selectRiskByCondition(@RequestBody TRiskInfoRequestDto riskInfoRequestDto) {
//        log.info("---------selectRiskByCondition begin, riskInfoRequestDto is {}----------", riskInfoRequestDto);
//        QueryWrapper<TRiskInfo> queryWrapper = new QueryWrapper<>();
//        if (!ObjectUtils.isEmpty(riskInfoRequestDto.getRiskInfoType())) {
//            queryWrapper.lambda().eq(TRiskInfo::getRiskInfoType, riskInfoRequestDto.getRiskInfoType());
//        }
//        if (!CollectionUtils.isEmpty(riskInfoRequestDto.getCustomerCodeList())) {
//            queryWrapper.lambda().in(TRiskInfo::getCustomerCode, riskInfoRequestDto.getCustomerCodeList());
//        }
//        if (!CollectionUtils.isEmpty(riskInfoRequestDto.getVehicleCodeList())) {
//            queryWrapper.lambda().in(TRiskInfo::getVehicleCode, riskInfoRequestDto.getVehicleCodeList());
//        }
//        if (!ObjectUtils.isEmpty(riskInfoRequestDto.getCreateStartTime())) {
//            queryWrapper.lambda().gt(TRiskInfo::getCreateTime, riskInfoRequestDto.getCreateStartTime());
//        }
//        if (!ObjectUtils.isEmpty(riskInfoRequestDto.getCreateEndTime())) {
//            queryWrapper.lambda().lt(TRiskInfo::getCreateTime, riskInfoRequestDto.getCreateEndTime());
//        }
//        List<TRiskInfo> tRiskInfoList = tRiskInfoService.list(queryWrapper);
//        List<TRiskInfoResponseDto> tRiskInfoResponseDtoList = tRiskInfoList.parallelStream().map(tRiskInfo -> {
//            TRiskInfoResponseDto tRiskInfoResponseDto = BeanUtil.copyProperties(tRiskInfo, TRiskInfoResponseDto.class);
//            if (RiskInfoTypeEnum.CUSTOMER.getValue().equals(String.valueOf(riskInfoRequestDto.getRiskInfoType()))) {
//                QueryWrapper<TVehicleInfo> queryWrapper1 = new QueryWrapper<>();
//                queryWrapper.lambda().eq(TRiskInfo::getCustomerCode, tRiskInfoResponseDto.getCustomerCode());
//                int count = tVehicleInfoService.count(queryWrapper1);
//                tRiskInfoResponseDto.setVehicleNumber(count);
//            } else {
//                QueryWrapper<TVehicleInfo> queryWrapper1 = new QueryWrapper<>();
//                queryWrapper1.lambda().eq(TVehicleInfo::getVehicleCode, tRiskInfoResponseDto.getVehicleCode());
//                TVehicleInfo tVehicleInfo = tVehicleInfoService.getOne(queryWrapper1);
//                if (!ObjectUtils.isEmpty(tVehicleInfo)) {
//                    tRiskInfoResponseDto.setCarNumber(tVehicleInfo.getCarNumber());
//                }
//            }
//            return tRiskInfoResponseDto;
//        }).collect(Collectors.toList());
//        log.info("---------selectRiskByCondition end, data is {}----------", tRiskInfoResponseDtoList);
//        return ApiResult.ok(tRiskInfoResponseDtoList);
//    }
//
//}
